home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / progutil / iostream.zoo / src / fstream.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-22  |  2.1 KB  |  99 lines

  1. //    This is part of the iostream library, providing input/output for C++.
  2. //    Copyright (C) 1991 Per Bothner.
  3. //
  4. //    This library is free software; you can redistribute it and/or
  5. //    modify it under the terms of the GNU Library General Public
  6. //    License as published by the Free Software Foundation; either
  7. //    version 2 of the License, or (at your option) any later version.
  8. //
  9. //    This library is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. //    Library General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU Library General Public
  15. //    License along with this library; if not, write to the Free
  16. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include "ioprivat.h"
  19. #include <fstream.h>
  20. #include <std.h>
  21. #include <sys/file.h>
  22. #ifdef __GNUG__
  23. #pragma implementation
  24. #endif
  25.  
  26. ifstream::ifstream()
  27. {
  28.     _strbuf = new filebuf();
  29. }
  30.  
  31. ifstream::ifstream(int fd)
  32. {
  33.     _strbuf = new filebuf(fd);
  34. }
  35.  
  36. ifstream::ifstream(char *name, int mode=ios::in, int prot=0664)
  37. {
  38. #if 1
  39.     _strbuf = new filebuf();
  40.     ((filebuf*)_strbuf)->open(name, mode, prot);
  41. #else
  42.     _flags |= ios::dont_close;
  43.     open(name, mode, prot);
  44. #endif
  45. }
  46.  
  47. ofstream::ofstream()
  48. {
  49.     _strbuf = new filebuf();
  50. }
  51.  
  52. ofstream::ofstream(int fd)
  53. {
  54.     _strbuf = new filebuf(fd);
  55. }
  56.  
  57. ofstream::ofstream(char *name, int mode=ios::out, int prot=0664)
  58. {
  59. #if 1
  60.     _strbuf = new filebuf();
  61.     ((filebuf*)_strbuf)->open(name, mode, prot);
  62. #else
  63.     _flags |= ios::dont_close;
  64.     open(name, mode, prot);
  65. #endif
  66. }
  67.  
  68. #if 0
  69. static int mode_to_sys(enum open_mode mode)
  70. {
  71.     return O_WRONLY;
  72. }
  73.  
  74. static char* fopen_cmd_arg(io_mode i)
  75. {
  76.     return "w";
  77. }
  78. #endif
  79.  
  80. void ifstream::open(char *name, int mode=ios::in, int prot=0664)
  81. {
  82.     rdbuf()->open(name, mode, prot);
  83. }
  84.  
  85. void ifstream::close()
  86. {
  87.     rdbuf()->close();
  88. }
  89.  
  90. void ofstream::close()
  91. {
  92.     rdbuf()->close();
  93. }
  94.  
  95. void ofstream::open(char *name, int mode=ios::out, int prot=0664)
  96. {
  97.     rdbuf()->open(name, mode, prot);
  98. }
  99.